package com.h3c.tj_nsh.UI.Activities;

import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;

import com.h3c.tj_nsh.R;
import com.h3c.tj_nsh.Utils.RetrofitUtils;
import com.h3c.tj_nsh.Utils.SystemBarTintManager;

import java.lang.ref.WeakReference;

import retrofit.Callback;

/**
 * Time: 2016/5/11.
 * Author:Chen  .
 */
public class BaseActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initSystemBar();
        overridePendingTransition(R.anim.next_in,R.anim.next_out);
    }
    private void initSystemBar() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            setTranslucentStatus(true);
        }
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        //使用颜色资源
        tintManager.setStatusBarTintResource(R.color.systemBar_color);
        //使用图片资源
        //tintManager.setStatusBarTintDrawable(getResources().getDrawable(R.drawable.ic_top_title_background));

    }


    @TargetApi(19)
    private void setTranslucentStatus(boolean on) {
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if (on) {
            winParams.flags |= bits;
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);
    }


}
